﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
	<head>
		<title></title>
        <script type="text/javascript" >
            window.attachEvent = window.attachEvent || window.addEventListener;
            window.onload = function () {
                //读身份证
                var idcardReader = document.getElementById("idcardReader");
                idcardReader.attachEvent("ReadComplete", function (e) {
                    alert("身份证读取："+(e.ReadStateCode=="0"));
                    document.getElementById("img").src = e.ImagePath;
                });
                idcardReader.ReadCard(1001);

                //读取ini配置
                var print = document.getElementById("ini");
                var result = print.ReadValue("Test", "uu", "G:\\openSource\\HCom\\t.ini");
                alert("读取配置：" + result);
                var v = "55555"
                print.WriteValue("Test", "uu", v, "G:\\openSource\\HCom\\t.ini");
                alert("写入：" + v);

                //出票
                var print = document.getElementById("dsPrinter");
                var result = print.OpenDevice("port desc");//端口，通常是出票号
                alert("打开：" + (result == true));
                var result = print.CloseDevice();
                alert("关闭：" + (result == true));
                var result = print.GetStatus();
                alert("状态：" + (result == true)); //其他状态:1,错误:2,就绪:3,正在打印:4,未连接:5,缺纸:6,夹纸器故障:7
                //print.MovePage("数值");//正数进，负数退，单位
                print.MovePage(22);
                var result = print.GetDefaultPrinter(); //获取默认打印机名称
                var result = print.SetDefaultPrinter("printerName");
                alert("设置结果：" + (result == true));

                //识别
                var rec = document.getElementById("rec");
                rec.attachEvent("CaptureComplete", function (e) {
                    alert("拍照结果：" + e.IsSuccess); //成功标志
                    alert("拍照结果：" + e.Error); //错误信息
                    alert("拍照结果：" + e.ImageSrc); //照片位置

                    var result = rec.RecFphm("http://127.0.0.1:9909/Services/InvRecognitionService.svc", e.ImageSrc, 10, 10, 130, 50); //识别服务地址，照片路径，号码区域，x,y,width,height，例如：http://127.0.0.1:9909/Services/InvRecognitionService.svc
                    alert("识别结果：code:" + result.Code + "|msg:" + result.Message + "|arg:" + result.Arguments); //返回结果对象
                });
                var cams = rec.GetCams(); //枚举系统已安装的摄像头参数，以逗号分隔。
                alert("系统摄像头：" + cams);
                var cam1 = cams.split(',');
                rec.CaptureCam(cam1); //打开设备并开始捕捉照片，然后通过事件返回图片信息

                //打印凭条，凭条模板参考附件
                var print = document.getElementById("print");
                var result = print.Print("某某业务", "办理成功", "执行xxx完毕，成功", "2018-02-28", "XXX公司", "91232143245324214324", "SEE001TERM", "XP-80C", "G:\\openSource\\HCom\\PrintTaxTester\\TAXTPL.html");
                if (!result) {
                    alert(print.ErrMsg);
                } else {
                    alert('打印成功');
                }
            };
            //document.getElementsByTagName('object')[0].ErrMsg
        </script>

	</head>
	<body>
        <object classid="clsid:B7E6AA9D-68AC-4BC9-8AC2-D19C66020B7F" id="idcardReader">
        </object>
        <object classid="clsid:E10813EE-4347-42D9-9F9A-772D6655CE67" id="ini">
        </object>
        <object classid="clsid:4C5F370B-14B9-4A0E-8574-97498AA443C9" id="dsPrinter">
        </object>
        <object classid="clsid:9F1A7845-9784-4361-A9B8-56ACE847005D" id="rec">
        </object>
	    <object classid="clsid:78836B01-70AB-4940-82A1-E51AE55F932D" id="print">
        </object>
        <img id="img" title="图片位置" alt="身份证照"/>
	</body>
</html>